import { onMounted, onUnmounted } from 'vue'

export function useTimer(action: TimerHandler, interval: number) {
  let id = 0
  onMounted(() => {
    id = setInterval(action, interval)
    console.debug('create timer: ', id)
  })
  onUnmounted(() => {
    console.debug('remove timer: ', id)
    clearInterval(id)
  })
}
